Is "}while(0);" always equal to "break;}while(1);" ?
Posted
by Hernán Eche
on Stack Overflow
See other posts from Stack Overflow
or by Hernán Eche
Published on 2010-06-11T14:48:55Z
Indexed on
2010/06/11
14:52 UTC
Read the original article
Hit count: 198
I have compared gcc assembler output of
do{
//some code
}while(0);
with
do{
//some code
break;
}while(1);
The output is equal, with or without optimization but..
It's always that way?
No experiment can prove theories, they can only show they are wrong
And because (I hope) programming is not an experimental science,
and results can be predicted (at least simple things) I want to be sure next time I reeplace a break;}while(1);
for the clearer (and less risky) while(0)
;
Thank you for reading
© Stack Overflow or respective owner